import { _decorator, Component, Label, Node, RigidBody2D } from 'cc';
import { PlayerManager } from './Player/PlayerManager';
const { ccclass, property } = _decorator;

@ccclass('MsgLable')
export class MsgLable extends Component {
    @property({ type: RigidBody2D }) msgLabel: RigidBody2D = null;
    @property({ type: PlayerManager }) player: PlayerManager = null;

    @property({ type: Label }) speedLabel: Label = null;
    @property({ type: Label }) stateLabel: Label = null;



    protected lateUpdate(dt: number): void {
        if(this.player.isInit)return;
        const speed = this.msgLabel.getComponent(RigidBody2D).linearVelocity;
        this.speedLabel.string = `speed:${speed.x.toFixed(2)},${speed.y.toFixed(2)}`;
        this.stateLabel.string = `state:${this.player.fsm.currState?.id}`;

    }
}


